package com.lc.guessTheWords.scene;

import android.view.KeyEvent;

import com.lc.guessTheWords.layer.ToolShopLayer;
import com.lc.guessTheWords.util.GameUtil;
import com.wiyun.engine.nodes.Director;
import com.wiyun.engine.nodes.Scene;

public class ToolShopScene extends Scene {
	private static ToolShopScene instance = null;
	private static Object sync_obj = new Object();

	ToolShopLayer layer;

	protected ToolShopScene() {
		layer = new ToolShopLayer();
		layer.setTouchEnabled(true);
		addChild(layer);
	}

	public static ToolShopScene make() {
		synchronized (sync_obj) {
			if (instance == null) {
				instance = new ToolShopScene();
			}
			return instance;
		}
	}

	public void updateCoins() {
		Director.getInstance().runOnGLThread(new Runnable() {

			@Override
			public void run() {
				layer.updateCount();
			}
		});

	}

	@Override
	public boolean wyKeyDown(KeyEvent event) {

		if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
			GameUtil.switchSceneTopSlide(MainScene.make());
			return true;
		}
		return super.wyKeyDown(event);
	}
}
